﻿import com.gamemeal.mvc.IDataHandler;
import com.gamemeal.mvc.datatype.MFObject;

/**
 * @author Colin
 */
class com.gamemeal.mvc.ModelDataHandler implements IDataHandler {
	private var successor : IDataHandler;
	
	public function getValue(modelField : MFObject):Object{
		if(modelField!=undefined){
			return modelField.value;
		}else if(successor!=null){
			successor.getValue(modelField);
		}else{
			throw new Error('Model Field Not found');
		}
	}

	public function setValue(modelField : MFObject, value : Object):Void {
		modelField.value = value;
	}

	public function setSuccessor(h : IDataHandler) : Void {
		successor = h;
	}

}